package com.sixth.controller;
import com.sixth.entity.Link;
import com.sixth.entity.TableResult;
import com.sixth.service.LinkService;
import com.sixth.until.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: self-tui-education
 * @description:
 * @author: C
 * @create: 2022-04-21 17:19
 **/
@RestController
@RequestMapping("/home/link")
public class LinkController {
    @Autowired
    private LinkService linkService;

    //友情链接查询功能
    @PostMapping("/getAllLink/{pageNum}/{pageSize}")
    private TableResult selectAllTeacher(@PathVariable Integer pageNum, @PathVariable Integer pageSize, @RequestBody Link link) {
        return linkService.selectAlllink(pageNum, pageSize, link);
    }

    //友情链接删除功能
    @PostMapping("/deleteLink")
    public CommonResult delete(@RequestBody Link link) {
       return  linkService.deleteFindById(link);
    }

    //友情链接修改方法和添加方法
    @PostMapping("/addLink")
    public CommonResult editRole(@RequestBody Link link){
        if (link.getLinkId()==null){
            return linkService.addZone(link);
        }else {
            return linkService.UpdateZone(link);
        }
    }
    //友情链接修改状态
    @PostMapping("/changeStatus/{linkId}/{isDisable}")
        public CommonResult changeStatus (@PathVariable String linkId , @PathVariable Integer isDisable){
            return linkService.changeStatus(linkId, isDisable);
        }

}
